<template>
  <div>
    <el-button @click="back" type="primary" size="medium" class="back-button"
      >返回</el-button
    >
  </div>
</template>

<script>
export default {
  name: "backButton",
  data() {
    return {};
  },
  props: {
    backPath: {
      type: String,
      default: "",
    },
  },
  methods: {
    back() {
      const { formQuery } = this.$route.query;
      if (this.backPath) {
        this.$router.push({
          path: this.backPath,
          query: {
            formQuery,
          }
        });
        return;
      }
      this.$router.back(-1);
    },
  },
};
</script>

<style lang="scss" scoped>
.back-button {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 1;
}
</style>
